const { resolve } = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')

// 为了让postcss生效而设置的环境变量
// process.env.NODE_ENV = 'development'

module.exports = {
  entry: resolve(__dirname, './src/js/index.js'),
  output: {
    filename: 'js/built.js',
    // 输出到的文件夹
    path: resolve(__dirname, 'build'),
  },
  plugins: [
    new HtmlWebpackPlugin({
      template: resolve(__dirname, './src/index.html'),
      minify: {
        // 移除空格
        collapseWhitespace: true,
        // 移除注释
        removeComments: true,
      },
    }),
  ],
  // 生产环境会自动压缩js代码
  mode: 'development',
  // mode: 'production',
}
